<template>
	<view class="layout">
		 子组件
		  <!-- 写法一 -->
		 <button @click="$emit('add', Math.random())">按钮</button>
		 <!-- 写法二 -->
		 <button @click="onClick">按钮-1</button>
		 
		 <input type="text" @input="onInput"/>
	</view>
</template>

<script setup>
	// 子传父
	const emit = defineEmits(['add', 'change'])
const onClick = () =>{
	emit('add', Math.random())
}

function onInput(e){	
	emit("change",e.detail.value)
}
</script>

<style lang="scss" scoped>
input{
	border:1px solid #cfcfcf;
	height: 40px;
}
</style>